package os_env

import (
	"fmt"
	logger "gitee.com/zaper/private-logger"
	"math/rand"
	"os"
)

const (
	ResisterCenterKey   = "ResisterCenterDns"
	ResisterCenterValue = "service-center.comb.com"
	ServiceNameKey      = "serviceName"
	ServiceNameValue    = "route-service"
)

var (
	ID        = rand.Intn(100000)
	ServiceId = fmt.Sprintf("%s-%d", ServiceNameValue, ID)
)

func InitializeEnv() {
	if err := os.Setenv(ResisterCenterKey, ResisterCenterValue); err != nil {
		logger.Errorf("set AppNameSpaceKey env fail, err is %s", err)
	}
	if err := os.Setenv(ServiceNameKey, ServiceNameValue); err != nil {
		logger.Errorf("set ServiceNameKey env fail, err is %s", err)
	}
	if err := os.Setenv("serviceId", ServiceId); err != nil {
		logger.Errorf("set AppNameSpaceKey env fail, err is %s", err)
	}
}
